﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;

using Fca.DataStructures;
using Fca.Algorithms;

namespace grid
{
    static class grid
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainFrm());
        }

        static private DiagramPainter DPainter;

        /// <summary>
        /// Test context
        /// </summary>
        public static void Test(ListView contextView, Panel DrawPanel)
        {
            bool[,] table = {   {true,	true,	true},
								{false,	true,	true},
								{false,	false,	true},
								{true,	false,	false}};

            string[] arrObjectNames = { "1", "2", "3", "4" };
            string[] arrAttributeNames = { "a", "b", "c" };

            contextView.Columns.Insert(0, "Objects");
            for (int i = 0; i < arrAttributeNames.Count(); i++)
            {
                contextView.Columns.Insert(i + 1, arrAttributeNames[i]);
            }

            for (int i = 0; i < arrObjectNames.Count(); i++)
            {
                ListViewItem lvItem = new ListViewItem(arrObjectNames[i]);
                for (int j = 0; j < arrAttributeNames.Count(); j++)
                {
                    lvItem.SubItems.Add(Convert.ToString(table[i, j]));
                }
                contextView.Items.Insert(i, lvItem);
            }

            Lattice l = new Lattice(table, arrObjectNames, arrAttributeNames);
            DPainter = new DiagramPainter(DrawPanel, l);
        }

        internal static void Paint()
        {
            DPainter.Draw();
        }
    }
}
